<!DOCTYPE html>


  <html class="dark page-post">


<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  
  <title>React Native之相机扫码 | Poetry&#39;s Blog</title>

  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  
    <meta name="keywords" content="react,RN,">
  

  <meta name="description" content="本文介绍react-native-camera扫码的应用 更多详情文档 https://github.com/react-native-community/react-native-camera   效果展示  配置 react-native link react-native-camera // 配置andriod/app/src/build.gradle defaultConfig &amp;#1">
<meta name="keywords" content="react,RN">
<meta property="og:type" content="article">
<meta property="og:title" content="React Native之相机扫码">
<meta property="og:url" content="http://blog.poetries.top/2019/10/02/rn-camera/index.html">
<meta property="og:site_name" content="Poetry&#39;s Blog">
<meta property="og:description" content="本文介绍react-native-camera扫码的应用 更多详情文档 https://github.com/react-native-community/react-native-camera   效果展示  配置 react-native link react-native-camera // 配置andriod/app/src/build.gradle defaultConfig &amp;#1">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://poetries1.gitee.io/img-repo/2019/10/676.png">
<meta property="og:updated_time" content="2020-08-15T04:25:31.934Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="React Native之相机扫码">
<meta name="twitter:description" content="本文介绍react-native-camera扫码的应用 更多详情文档 https://github.com/react-native-community/react-native-camera   效果展示  配置 react-native link react-native-camera // 配置andriod/app/src/build.gradle defaultConfig &amp;#1">
<meta name="twitter:image" content="https://poetries1.gitee.io/img-repo/2019/10/676.png">

  

  
    <link rel="icon" href="/favicon.ico">
  

  <link href="/css/styles.css?v=c114cbeddx" rel="stylesheet">
<link href="/css/other.css?v=c114cbeddx" rel="stylesheet">


  
    <link rel="stylesheet" href="/css/personal-style.css">
  

  

  
  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?40b1f89aa80f2527b3db779c6898c879";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>


  
  <script type="text/javascript">
	(function(){
	    var bp = document.createElement('script');
	    var curProtocol = window.location.protocol.split(':')[0];
	    if (curProtocol === 'https') {
	        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
	    }
	    else {
	        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
	    }
	    var s = document.getElementsByTagName("script")[0];
	    s.parentNode.insertBefore(bp, s);
	})();
  </script>



  
    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.3.0/css/font-awesome.min.css">
  

  <!-- 聊天系统 -->
  
    
   <link type="text/css" rel="stylesheet" href="/renxi/default.css">
   <style>
      #modal {
        position: static !important;
      }
      .filter {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        background: #fe5757;
        animation: colorChange 30s ease-in-out infinite;
        animation-fill-mode: both;
        mix-blend-mode: overlay;
      }
  
      @keyframes colorChange {
        0%, 100% {
            opacity: 0;
        }
        50% {
            opacity: .9;
        }
      }
   </style>
</head>
</html>
<body>
  
  
    <span id="toolbox-mobile" class="toolbox-mobile">导航</span>
  

  <div class="post-header CENTER">
   
  <div class="toolbox">
    <a class="toolbox-entry" href="/">
      <span class="toolbox-entry-text">导航</span>
      <i class="icon-angle-down"></i>
      <i class="icon-home"></i>
    </a>
    <ul class="list-toolbox">
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/archives/"
            rel="noopener noreferrer"
            target="_self"
            >
            博客
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/categories/"
            rel="noopener noreferrer"
            target="_self"
            >
            分类
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/tags/"
            rel="noopener noreferrer"
            target="_self"
            >
            标签
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/search/"
            rel="noopener noreferrer"
            target="_self"
            >
            搜索
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/link/"
            rel="noopener noreferrer"
            target="_self"
            >
            友链
          </a>
        </li>
      
        <li class="item-toolbox">
          <a
            class="CIRCLE"
            href="/about/"
            rel="noopener noreferrer"
            target="_self"
            >
            关于
          </a>
        </li>
      
    </ul>
  </div>


</div>





<div class="content content-post CENTER">
   <!-- canvas 彩带 -->
<canvas id="evanyou" width="1302" height="678" style="position: fixed;width: 100%;height: 100%;top: 0;left:0;z-index:-1;"></canvas>

<article id="post-rn-camera" class="article article-type-post" itemprop="blogPost">
  <header class="article-header" style="position:relative;">
    <h1 class="post-title">React Native之相机扫码</h1>

    <div class="article-meta">
      <span>
        <i class="icon-calendar"></i>
        <span>2019.10.02</span>
      </span>

      
        <span class="article-author">
          <i class="icon-user"></i>
          <span>Poetry</span>
        </span>
      

      
  <span class="article-category">
    <i class="icon-list"></i>
    <a class="article-category-link" href="/categories/Front-End/">Front-End</a>
  </span>



      

      
      <i class="fa fa-eye"></i> 
        <span id="busuanzi_container_page_pv">
           &nbsp热度 <span id="busuanzi_value_page_pv">
           <i class="fa fa-spinner fa-spin"></i></span>℃
        </span>
      
      
       
          <span class="post-count">
            <i class="fa fa-file-word-o"></i>&nbsp
            <span>字数统计 1.6k字</span>
          </span>

          <span class="post-count">
            <i class="fa fa-columns"></i>&nbsp
            <span>阅读时长 9分</span>
          </span>
      
      
    </div>

    <i class="iconfont" id="toc-eye" style="display:inline-block;color:#b36619;position:absolute;top:0;right:0;cursor:pointer;
    font-size: 24px;">&#xe61c;</i>

  </header>

  <div class="article-content">
    
      <div id="container">
        <blockquote>
<ul>
<li>本文介绍<code>react-native-camera</code>扫码的应用</li>
<li>更多详情文档 <a href="https://github.com/react-native-community/react-native-camera" target="_blank" rel="noopener">https://github.com/react-native-community/react-native-camera</a></li>
</ul>
</blockquote>
<p><strong>效果展示</strong></p>
<p><img src="https://poetries1.gitee.io/img-repo/2019/10/676.png" alt></p>
<p><strong>配置</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">react-native link react-native-camera</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// 配置andriod/app/src/build.gradle </span></span><br><span class="line"></span><br><span class="line">defaultConfig &#123;</span><br><span class="line">    applicationId <span class="string">"com.jtyapps"</span></span><br><span class="line">    minSdkVersion rootProject.ext.minSdkVersion</span><br><span class="line">    targetSdkVersion rootProject.ext.targetSdkVersion</span><br><span class="line">    versionCode <span class="number">1</span></span><br><span class="line">    versionName <span class="string">"1.0"</span></span><br><span class="line">    ndk &#123;</span><br><span class="line">        abiFilters <span class="string">"armeabi-v7a"</span>, <span class="string">"x86"</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">// 添加这里</span></span><br><span class="line">    missingDimensionStrategy <span class="string">'react-native-camera'</span>, <span class="string">'general'</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 配置andriod/gradle/wrapper/gradle-wrapper.properties</span></span><br><span class="line"><span class="comment">// 本教程使用的是这个版本</span></span><br><span class="line">distributionUrl=https\:<span class="comment">//services.gradle.org/distributions/gradle-4.10.1-all.zip</span></span><br></pre></td></tr></table></figure>
<p><strong>添加相机权限</strong></p>
<blockquote>
<p><code>andriod/app/src/main/AndroidManifest.xml</code></p>
</blockquote>
<figure class="highlight html"><table><tr><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.BLUETOOTH"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.BLUETOOTH_ADMIN"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.ACCESS_FINE_LOCATION"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.ACCESS_COARSE_LOCATION"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.CHANGE_NETWORK_STATE"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.CHANGE_WIFI_STATE"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.ACCESS_WIFI_STATE"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.ACCESS_NETWORK_STATE"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.READ_EXTERNAL_STORAGEE"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.WRITE_EXTERNAL_STORAGE"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.INTERNET"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.SYSTEM_ALERT_WINDOW"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.CAMERA"</span>/&gt;</span> </span><br><span class="line"><span class="tag">&lt;<span class="name">uses-permission</span> <span class="attr">android:name</span>=<span class="string">"android.permission.VIBRATE"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-feature</span> <span class="attr">android:name</span>=<span class="string">"android.hardware.camera"</span> <span class="attr">android:required</span>=<span class="string">"false"</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">uses-feature</span> <span class="attr">android:name</span>=<span class="string">"android.hardware.camera.front"</span> <span class="attr">android:required</span>=<span class="string">"false"</span>/&gt;</span></span><br></pre></td></tr></table></figure>
<p><strong>处理逻辑</strong></p>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// scan.js</span></span><br><span class="line"><span class="keyword">import</span> React, &#123; Component &#125; <span class="keyword">from</span> <span class="string">'react'</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> &#123;</span><br><span class="line">    View,</span><br><span class="line">    Text,</span><br><span class="line">    StyleSheet,</span><br><span class="line">    Image,</span><br><span class="line">    Platform,</span><br><span class="line">    Vibration,</span><br><span class="line">    TouchableOpacity,</span><br><span class="line">    Animated,</span><br><span class="line">    Easing,</span><br><span class="line">    Dimensions,</span><br><span class="line">    StatusBar</span><br><span class="line">&#125; <span class="keyword">from</span> <span class="string">'react-native'</span>;</span><br><span class="line"><span class="keyword">import</span> Icon <span class="keyword">from</span> <span class="string">'react-native-vector-icons/Feather'</span>;</span><br><span class="line"><span class="keyword">const</span> &#123; width, height &#125; = Dimensions.get(<span class="string">'window'</span>);</span><br><span class="line"><span class="keyword">import</span> &#123; Modal &#125; <span class="keyword">from</span> <span class="string">'@ant-design/react-native'</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> &#123;RNCamera&#125; <span class="keyword">from</span> <span class="string">'react-native-camera'</span>;</span><br><span class="line"><span class="keyword">import</span> ViewFinder <span class="keyword">from</span> <span class="string">'./ViewFinder'</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> scanLine <span class="keyword">from</span> <span class="string">'../../assets/images/scan_line.png'</span>;</span><br><span class="line"><span class="keyword">import</span> &#123; scaleSizeW, scaleSizeH, setSpText &#125; <span class="keyword">from</span> <span class="string">'../../utils/scale'</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> <span class="class"><span class="keyword">class</span> <span class="title">MyScan</span> <span class="keyword">extends</span> <span class="title">Component</span> </span>&#123;</span><br><span class="line">    <span class="keyword">static</span> navigationOptions = <span class="function">(<span class="params">&#123; navigation, navigationOptions &#125;</span>) =&gt;</span> &#123;</span><br><span class="line">		<span class="keyword">return</span>(&#123;</span><br><span class="line">			header: <span class="literal">null</span></span><br><span class="line">		&#125;)</span><br><span class="line">	&#125;;</span><br><span class="line">    <span class="keyword">constructor</span>(props) &#123;</span><br><span class="line">        <span class="keyword">super</span>(props);</span><br><span class="line">        <span class="keyword">this</span>.camera = <span class="literal">null</span>;</span><br><span class="line">        <span class="keyword">this</span>.state = &#123;</span><br><span class="line">            openFlash: <span class="literal">false</span>,</span><br><span class="line">            active: <span class="literal">true</span>,</span><br><span class="line">            flag: <span class="literal">true</span>,</span><br><span class="line">            fadeInOpacity: <span class="keyword">new</span> Animated.Value(<span class="number">0</span>), <span class="comment">// 初始值</span></span><br><span class="line">            isEndAnimation: <span class="literal">false</span>,<span class="comment">//结束动画标记</span></span><br><span class="line">            key: <span class="string">''</span></span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">    componentDidMount() &#123;</span><br><span class="line">        <span class="keyword">const</span> &#123;navigation&#125; = <span class="keyword">this</span>.props;</span><br><span class="line">    </span><br><span class="line">        <span class="keyword">this</span>._startAnimation(<span class="literal">false</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    componentWillReceiveProps(nProps) &#123;</span><br><span class="line">        <span class="keyword">const</span> &#123;key &#125; = <span class="keyword">this</span>.state;</span><br><span class="line">        <span class="keyword">const</span> &#123;navigation&#125; = nProps;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">let</span> newKey = navigation.getParam(<span class="string">'key'</span>);</span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span>(key!=newKey)&#123;</span><br><span class="line">            <span class="keyword">this</span>.transCode = <span class="string">''</span>;</span><br><span class="line">            <span class="keyword">this</span>.setState(&#123;</span><br><span class="line">                key: newKey</span><br><span class="line">            &#125;)</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="built_in">console</span>.log(<span class="string">'scan进来了'</span>)</span><br><span class="line">      &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//开始动画，循环播放</span></span><br><span class="line">    _startAnimation = <span class="function">(<span class="params">isEnd</span>) =&gt;</span> &#123;</span><br><span class="line">        Animated.timing(<span class="keyword">this</span>.state.fadeInOpacity, &#123;</span><br><span class="line">            toValue: <span class="number">1</span>,</span><br><span class="line">            duration: <span class="number">3000</span>,</span><br><span class="line">            easing: Easing.linear</span><br><span class="line">        &#125;).start(</span><br><span class="line">            () =&gt; &#123;</span><br><span class="line">                <span class="keyword">if</span> (isEnd) &#123;</span><br><span class="line">                    <span class="keyword">this</span>.setState(&#123;</span><br><span class="line">                        isEndAnimation: <span class="literal">true</span></span><br><span class="line">                    &#125;)</span><br><span class="line">                    <span class="keyword">return</span>;</span><br><span class="line">                &#125;</span><br><span class="line">                <span class="keyword">if</span> (!<span class="keyword">this</span>.state.isEndAnimation) &#123;</span><br><span class="line">                    <span class="keyword">this</span>.state.fadeInOpacity.setValue(<span class="number">0</span>);</span><br><span class="line">                    <span class="keyword">this</span>._startAnimation(<span class="literal">false</span>)</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        );</span><br><span class="line">        <span class="comment">// console.log("开始动画");</span></span><br><span class="line">    &#125;</span><br><span class="line">    barcodeReceived (e)&#123;</span><br><span class="line">        <span class="keyword">const</span> &#123;<span class="attr">navigation</span>:&#123;navigate&#125;&#125; = <span class="keyword">this</span>.props;</span><br><span class="line">        <span class="keyword">if</span> (e.data !== <span class="keyword">this</span>.transCode) &#123;</span><br><span class="line">            Vibration.vibrate([<span class="number">0</span>, <span class="number">500</span>, <span class="number">200</span>, <span class="number">500</span>]);</span><br><span class="line">            <span class="keyword">this</span>.transCode = e.data; <span class="comment">// 放在this上，防止触发多次，setstate有延时</span></span><br><span class="line">            <span class="keyword">if</span> (<span class="keyword">this</span>.state.flag) &#123;</span><br><span class="line">                <span class="keyword">this</span>.changeState(<span class="literal">false</span>);</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="built_in">console</span>.log(<span class="string">"transCode="</span> + <span class="keyword">this</span>.transCode);</span><br><span class="line">            Modal.alert(<span class="string">'温馨提示'</span>, <span class="string">`确定绑定: <span class="subst">$&#123;<span class="keyword">this</span>.transCode&#125;</span> 吗？`</span>, [</span><br><span class="line">                &#123;</span><br><span class="line">                  text: <span class="string">'取消'</span>,</span><br><span class="line">                  onPress: <span class="function"><span class="params">()</span> =&gt;</span> <span class="built_in">console</span>.log(<span class="string">'cancel'</span>),</span><br><span class="line">                  style: <span class="string">'cancel'</span>,</span><br><span class="line">                &#125;,</span><br><span class="line">                &#123; <span class="attr">text</span>: <span class="string">'确定'</span>, <span class="attr">onPress</span>: <span class="function"><span class="params">()</span> =&gt;</span> &#123;</span><br><span class="line">                    navigate(<span class="string">'Record'</span>)</span><br><span class="line">                    <span class="comment">// dispatch(&#123;</span></span><br><span class="line">                    <span class="comment">//     type: 'user/bindHeartDev',</span></span><br><span class="line">                    <span class="comment">//     callback: res=&gt;&#123;</span></span><br><span class="line">                    <span class="comment">//         if(res.code == 200) &#123;</span></span><br><span class="line">                    <span class="comment">//             navigate('Record')</span></span><br><span class="line">                    <span class="comment">//         &#125;</span></span><br><span class="line">                    <span class="comment">//     &#125;</span></span><br><span class="line">                    <span class="comment">// &#125;)</span></span><br><span class="line">                &#125; &#125;,</span><br><span class="line">            ]);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//返回按钮点击事件</span></span><br><span class="line">    _goBack = <span class="function"><span class="params">()</span> =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">this</span>.setState(&#123;</span><br><span class="line">            isEndAnimation: <span class="literal">true</span>,</span><br><span class="line">        &#125;);</span><br><span class="line">        <span class="keyword">this</span>.props.navigation.goBack();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//开灯关灯</span></span><br><span class="line">    _changeFlash = <span class="function"><span class="params">()</span> =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">this</span>.setState(&#123;</span><br><span class="line">            openFlash: !<span class="keyword">this</span>.state.openFlash,</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//改变请求状态</span></span><br><span class="line">    changeState = <span class="function">(<span class="params">status</span>) =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">this</span>.setState(&#123;</span><br><span class="line">            flag: status</span><br><span class="line">        &#125;);</span><br><span class="line">        <span class="built_in">console</span>.log(<span class="string">'status='</span> + status);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    render() &#123;</span><br><span class="line">        <span class="keyword">const</span> &#123;</span><br><span class="line">            openFlash,</span><br><span class="line">            active,</span><br><span class="line">        &#125; = <span class="keyword">this</span>.state;</span><br><span class="line">        <span class="keyword">return</span> (</span><br><span class="line">            &lt;View style=&#123;styles.allContainer&#125;&gt;</span><br><span class="line">                &lt;RNCamera</span><br><span class="line">                    barCodeTypes=&#123;[RNCamera.Constants.BarCodeType.qr]&#125;</span><br><span class="line">                    onBarCodeRead=&#123;<span class="keyword">this</span>.barcodeReceived.bind(<span class="keyword">this</span>)&#125;</span><br><span class="line">                    onCameraReady=&#123;() =&gt; &#123;</span><br><span class="line">                        <span class="built_in">console</span>.log(<span class="string">'ready'</span>)</span><br><span class="line">                    &#125;&#125;</span><br><span class="line">                    permissionDialogTitle=&#123;<span class="string">'Permission to use camera'</span>&#125;</span><br><span class="line">                    permissionDialogMessage=&#123;<span class="string">'We need your permission to use your camera phone'</span>&#125;</span><br><span class="line">                    <span class="comment">// defaultVideoQuality=&#123;RNCamera.Constants.VideoQuality["480p"]&#125;</span></span><br><span class="line">                    style=&#123;styles.cameraStyle&#125;</span><br><span class="line">                &gt;</span><br><span class="line">                    &lt;View style=&#123;styles.container&#125;&gt;</span><br><span class="line">                        &lt;View style=&#123;styles.titleContainer&#125;&gt;</span><br><span class="line">                            &lt;View style=&#123;styles.leftContainer&#125;&gt;</span><br><span class="line">                                &lt;TouchableOpacity activeOpacity=&#123;<span class="number">1</span>&#125; onPress=&#123;<span class="keyword">this</span>._goBack&#125;&gt;</span><br><span class="line">                                    &lt;View&gt;</span><br><span class="line">                                        &#123;<span class="comment">/* &lt;Image style=&#123;styles.backImg&#125; source=&#123;backIcon&#125; /&gt; */</span>&#125;</span><br><span class="line">                                        &lt;Icon name=<span class="string">"chevron-left"</span> style=&#123;styles.backIcon&#125;/&gt;</span><br><span class="line">                                    &lt;<span class="regexp">/View&gt;</span></span><br><span class="line"><span class="regexp">                                &lt;/</span>TouchableOpacity&gt;</span><br><span class="line">                            &lt;<span class="regexp">/View&gt;</span></span><br><span class="line"><span class="regexp">                        &lt;/</span>View&gt;</span><br><span class="line">                    &lt;<span class="regexp">/View&gt;</span></span><br><span class="line"><span class="regexp">                    &lt;View style=&#123;styles.centerContainer&#125; /</span>&gt;</span><br><span class="line">                    &lt;View style=&#123;&#123; <span class="attr">flexDirection</span>: <span class="string">'row'</span> &#125;&#125;&gt;</span><br><span class="line">                        &lt;View style=&#123;styles.fillView&#125; /&gt;</span><br><span class="line">                        &lt;View style=&#123;styles.scan&#125;&gt;</span><br><span class="line">                            &lt;ViewFinder /&gt;</span><br><span class="line">                            &lt;Animated.View style=&#123;[styles.scanLine, &#123;</span><br><span class="line">                                opacity: <span class="number">1</span>,</span><br><span class="line">                                transform: [&#123;</span><br><span class="line">                                    translateY: <span class="keyword">this</span>.state.fadeInOpacity.interpolate(&#123;</span><br><span class="line">                                        inputRange: [<span class="number">0</span>, <span class="number">1</span>],</span><br><span class="line">                                        outputRange: [<span class="number">0</span>, scaleSizeH(<span class="number">300</span>)]</span><br><span class="line">                                    &#125;)</span><br><span class="line">                                &#125;]</span><br><span class="line">                            &#125;]&#125;&gt;</span><br><span class="line">                                &lt;Image source=&#123;scanLine&#125; /&gt;</span><br><span class="line">                            &lt;<span class="regexp">/Animated.View&gt;</span></span><br><span class="line"><span class="regexp">                        &lt;/</span>View&gt;</span><br><span class="line">                        &lt;View style=&#123;styles.fillView&#125; /&gt;</span><br><span class="line">                    &lt;<span class="regexp">/View&gt;</span></span><br><span class="line"><span class="regexp">                    &lt;View style=&#123;styles.bottomContainer&#125;&gt;</span></span><br><span class="line"><span class="regexp">                        &lt;Text</span></span><br><span class="line"><span class="regexp">                            style=&#123;[</span></span><br><span class="line"><span class="regexp">                                styles.text,</span></span><br><span class="line"><span class="regexp">                                &#123;</span></span><br><span class="line"><span class="regexp">                                    textAlign: 'center',</span></span><br><span class="line"><span class="regexp">                                    width: 220,</span></span><br><span class="line"><span class="regexp">                                    marginTop: active ? 25 : 245,</span></span><br><span class="line"><span class="regexp">                                &#125;,</span></span><br><span class="line"><span class="regexp">                            ]&#125;</span></span><br><span class="line"><span class="regexp">                            numberOfLines=&#123;2&#125;</span></span><br><span class="line"><span class="regexp">                        &gt;</span></span><br><span class="line"><span class="regexp">                            请将手表二维码放入扫码框内</span></span><br><span class="line"><span class="regexp">                                &lt;/</span>Text&gt;</span><br><span class="line">                       &#123;<span class="comment">/** &lt;TouchableOpacity onPress=&#123;this._changeFlash&#125;&gt;</span></span><br><span class="line"><span class="comment">                            &lt;View style=&#123;styles.flash&#125;&gt;</span></span><br><span class="line"><span class="comment">                                &lt;Text style=&#123;styles.icon&#125;&gt;(・◇・)&lt;/Text&gt;</span></span><br><span class="line"><span class="comment">                                &lt;Text style=&#123;styles.text&#125;&gt;</span></span><br><span class="line"><span class="comment">                                    开灯/关灯</span></span><br><span class="line"><span class="comment">                                        &lt;/Text&gt;</span></span><br><span class="line"><span class="comment">                            &lt;/View&gt;</span></span><br><span class="line"><span class="comment">                        &lt;/TouchableOpacity&gt;  */</span>&#125;</span><br><span class="line">                        </span><br><span class="line">                    &lt;<span class="regexp">/View&gt;</span></span><br><span class="line"><span class="regexp">                &lt;/</span>RNCamera&gt; </span><br><span class="line">            &lt;<span class="regexp">/View&gt;</span></span><br><span class="line"><span class="regexp">        )</span></span><br><span class="line"><span class="regexp">    &#125;</span></span><br><span class="line"><span class="regexp">&#125;</span></span><br><span class="line"><span class="regexp"></span></span><br><span class="line"><span class="regexp">const styles = StyleSheet.create(&#123;</span></span><br><span class="line"><span class="regexp">    allContainer: &#123;</span></span><br><span class="line"><span class="regexp">        flex: 1,</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    container: &#123;</span></span><br><span class="line"><span class="regexp">        ...Platform.select(&#123;</span></span><br><span class="line"><span class="regexp">            ios: &#123;</span></span><br><span class="line"><span class="regexp">                height: 64 + StatusBar.currentHeight,</span></span><br><span class="line"><span class="regexp">            &#125;,</span></span><br><span class="line"><span class="regexp">            android: &#123;</span></span><br><span class="line"><span class="regexp">                height: 50 + StatusBar.currentHeight,</span></span><br><span class="line"><span class="regexp">            &#125;</span></span><br><span class="line"><span class="regexp">        &#125;),</span></span><br><span class="line"><span class="regexp">        backgroundColor: '#000',</span></span><br><span class="line"><span class="regexp">        opacity: 0.5</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    titleContainer: &#123;</span></span><br><span class="line"><span class="regexp">        flex: 1,</span></span><br><span class="line"><span class="regexp">        ...Platform.select(&#123;</span></span><br><span class="line"><span class="regexp">            ios: &#123;</span></span><br><span class="line"><span class="regexp">                paddingTop: 15,</span></span><br><span class="line"><span class="regexp">            &#125;,</span></span><br><span class="line"><span class="regexp">            android: &#123;</span></span><br><span class="line"><span class="regexp">                paddingTop: 0,</span></span><br><span class="line"><span class="regexp">            &#125;</span></span><br><span class="line"><span class="regexp">        &#125;),</span></span><br><span class="line"><span class="regexp">        flexDirection: 'row',</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    leftContainer: &#123;</span></span><br><span class="line"><span class="regexp">        flex: 0,</span></span><br><span class="line"><span class="regexp">        justifyContent: 'center',</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    backIcon: &#123;</span></span><br><span class="line"><span class="regexp">        marginLeft: 10,</span></span><br><span class="line"><span class="regexp">        fontSize: 30,</span></span><br><span class="line"><span class="regexp">        color: '#fff'</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    cameraStyle: &#123;</span></span><br><span class="line"><span class="regexp">        alignSelf: 'center',</span></span><br><span class="line"><span class="regexp">        width: width,</span></span><br><span class="line"><span class="regexp">        height: height,</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    flash: &#123;</span></span><br><span class="line"><span class="regexp">        flexDirection: 'column',</span></span><br><span class="line"><span class="regexp">        alignItems: 'center',</span></span><br><span class="line"><span class="regexp">        justifyContent: 'flex-start',</span></span><br><span class="line"><span class="regexp">        marginTop: 60,</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    flashIcon: &#123;</span></span><br><span class="line"><span class="regexp">        fontSize: 1,</span></span><br><span class="line"><span class="regexp">        color: '#fff',</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    text: &#123;</span></span><br><span class="line"><span class="regexp">        fontSize: 14,</span></span><br><span class="line"><span class="regexp">        color: '#fff',</span></span><br><span class="line"><span class="regexp">        marginTop: 5</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    icon: &#123;</span></span><br><span class="line"><span class="regexp">        color: '#fff',</span></span><br><span class="line"><span class="regexp">        fontSize: 20,</span></span><br><span class="line"><span class="regexp">        fontFamily: 'iconfont'</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    scanLine: &#123;</span></span><br><span class="line"><span class="regexp">        alignSelf: 'center',</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    centerContainer: &#123;</span></span><br><span class="line"><span class="regexp">        ...Platform.select(&#123;</span></span><br><span class="line"><span class="regexp">            ios: &#123;</span></span><br><span class="line"><span class="regexp">                height: 80,</span></span><br><span class="line"><span class="regexp">            &#125;,</span></span><br><span class="line"><span class="regexp">            android: &#123;</span></span><br><span class="line"><span class="regexp">                height: 60,</span></span><br><span class="line"><span class="regexp">            &#125;</span></span><br><span class="line"><span class="regexp">        &#125;),</span></span><br><span class="line"><span class="regexp">        width: width,</span></span><br><span class="line"><span class="regexp">        backgroundColor: '#000',</span></span><br><span class="line"><span class="regexp">        opacity: 0.5</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    bottomContainer: &#123;</span></span><br><span class="line"><span class="regexp">        alignItems: 'center',</span></span><br><span class="line"><span class="regexp">        backgroundColor: '#000',</span></span><br><span class="line"><span class="regexp">        alignSelf: 'center',</span></span><br><span class="line"><span class="regexp">        opacity: 0.5,</span></span><br><span class="line"><span class="regexp">        flex: 1,</span></span><br><span class="line"><span class="regexp">        width: width</span></span><br><span class="line"><span class="regexp">    &#125;,</span></span><br><span class="line"><span class="regexp">    fillView: &#123;</span></span><br><span class="line"><span class="regexp">        width: (width - scaleSizeH(300)) /</span> <span class="number">2</span>,</span><br><span class="line">        height: scaleSizeH(<span class="number">300</span>),</span><br><span class="line">        backgroundColor: <span class="string">'#000'</span>,</span><br><span class="line">        opacity: <span class="number">0.5</span></span><br><span class="line">    &#125;,</span><br><span class="line">    scan: &#123;</span><br><span class="line">        width: scaleSizeH(<span class="number">300</span>),</span><br><span class="line">        height: scaleSizeH(<span class="number">300</span>),</span><br><span class="line">        alignSelf: <span class="string">'center'</span></span><br><span class="line">    &#125;,</span><br><span class="line">    info:&#123;</span><br><span class="line">        color: <span class="string">'#fff'</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// ViewFinder.js</span></span><br><span class="line"><span class="keyword">import</span> React, &#123;</span><br><span class="line">    Component,</span><br><span class="line">&#125; <span class="keyword">from</span> <span class="string">'react'</span>;</span><br><span class="line"><span class="keyword">import</span> &#123;</span><br><span class="line">    ActivityIndicator,</span><br><span class="line">    StyleSheet,</span><br><span class="line">    View,</span><br><span class="line">&#125; <span class="keyword">from</span> <span class="string">'react-native'</span>;</span><br><span class="line"><span class="keyword">import</span> &#123; scaleSizeW, scaleSizeH, setSpText &#125; <span class="keyword">from</span> <span class="string">'../../utils/scale'</span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> <span class="class"><span class="keyword">class</span> <span class="title">Viewfinder</span> <span class="keyword">extends</span> <span class="title">Component</span> </span>&#123;</span><br><span class="line">    <span class="keyword">constructor</span>(props) &#123;</span><br><span class="line">        <span class="keyword">super</span>(props);</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    getBackgroundColor = <span class="function"><span class="params">()</span> =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> (&#123;</span><br><span class="line">            backgroundColor: <span class="keyword">this</span>.props.backgroundColor,</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    getEdgeColor = <span class="function"><span class="params">()</span> =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> (&#123;</span><br><span class="line">            borderColor: <span class="keyword">this</span>.props.color,</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    getSizeStyles = <span class="function"><span class="params">()</span> =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> (&#123;</span><br><span class="line">            height: <span class="keyword">this</span>.props.height,</span><br><span class="line">            width: <span class="keyword">this</span>.props.width,</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    getEdgeSizeStyles = <span class="function"><span class="params">()</span> =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">return</span> (&#123;</span><br><span class="line">            height: <span class="keyword">this</span>.props.borderLength,</span><br><span class="line">            width: <span class="keyword">this</span>.props.borderLength,</span><br><span class="line">        &#125;);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    renderLoadingIndicator = <span class="function"><span class="params">()</span> =&gt;</span> &#123;</span><br><span class="line">        <span class="keyword">if</span> (!<span class="keyword">this</span>.props.isLoading) &#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="literal">null</span>;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> (</span><br><span class="line">            &lt;ActivityIndicator</span><br><span class="line">                animating=&#123;<span class="keyword">this</span>.props.isLoading&#125;</span><br><span class="line">                color=&#123;<span class="keyword">this</span>.props.color&#125;</span><br><span class="line">                size=<span class="string">"large"</span></span><br><span class="line">            /&gt;</span><br><span class="line">        );</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    render() &#123;</span><br><span class="line">        <span class="keyword">return</span> (</span><br><span class="line">            &lt;View style=&#123;[styles.container, <span class="keyword">this</span>.getBackgroundColor()]&#125;&gt;</span><br><span class="line">                &lt;View style=&#123;[styles.viewfinder, <span class="keyword">this</span>.getSizeStyles()]&#125;&gt;</span><br><span class="line">                    &lt;View</span><br><span class="line">                        style=&#123;[</span><br><span class="line">                            <span class="keyword">this</span>.getEdgeColor(),</span><br><span class="line">                            <span class="keyword">this</span>.getEdgeSizeStyles(),</span><br><span class="line">                            styles.topLeftEdge,</span><br><span class="line">                            &#123;</span><br><span class="line">                                borderLeftWidth: <span class="keyword">this</span>.props.borderWidth,</span><br><span class="line">                                borderTopWidth: <span class="keyword">this</span>.props.borderWidth,</span><br><span class="line">                            &#125;,</span><br><span class="line">                        ]&#125;</span><br><span class="line">                    /&gt;</span><br><span class="line">                    &lt;View</span><br><span class="line">                        style=&#123;[</span><br><span class="line">                            <span class="keyword">this</span>.getEdgeColor(),</span><br><span class="line">                            <span class="keyword">this</span>.getEdgeSizeStyles(),</span><br><span class="line">                            styles.topRightEdge,</span><br><span class="line">                            &#123;</span><br><span class="line">                                borderRightWidth: <span class="keyword">this</span>.props.borderWidth,</span><br><span class="line">                                borderTopWidth: <span class="keyword">this</span>.props.borderWidth,</span><br><span class="line">                            &#125;,</span><br><span class="line">                        ]&#125;</span><br><span class="line">                    /&gt;</span><br><span class="line">                    &#123;<span class="keyword">this</span>.renderLoadingIndicator()&#125;</span><br><span class="line">                    &lt;View</span><br><span class="line">                        style=&#123;[</span><br><span class="line">                            <span class="keyword">this</span>.getEdgeColor(),</span><br><span class="line">                            <span class="keyword">this</span>.getEdgeSizeStyles(),</span><br><span class="line">                            styles.bottomLeftEdge,</span><br><span class="line">                            &#123;</span><br><span class="line">                                borderLeftWidth: <span class="keyword">this</span>.props.borderWidth,</span><br><span class="line">                                borderBottomWidth: <span class="keyword">this</span>.props.borderWidth,</span><br><span class="line">                            &#125;,</span><br><span class="line">                        ]&#125;</span><br><span class="line">                    /&gt;</span><br><span class="line">                    &lt;View</span><br><span class="line">                        style=&#123;[</span><br><span class="line">                            <span class="keyword">this</span>.getEdgeColor(),</span><br><span class="line">                            <span class="keyword">this</span>.getEdgeSizeStyles(),</span><br><span class="line">                            styles.bottomRightEdge,</span><br><span class="line">                            &#123;</span><br><span class="line">                                borderRightWidth: <span class="keyword">this</span>.props.borderWidth,</span><br><span class="line">                                borderBottomWidth: <span class="keyword">this</span>.props.borderWidth,</span><br><span class="line">                            &#125;,</span><br><span class="line">                        ]&#125;</span><br><span class="line">                    /&gt;</span><br><span class="line">                &lt;<span class="regexp">/View&gt;</span></span><br><span class="line"><span class="regexp">            &lt;/</span>View&gt;</span><br><span class="line">        );</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">const</span> styles = StyleSheet.create(&#123;</span><br><span class="line">    container: &#123;</span><br><span class="line">        alignItems: <span class="string">'center'</span>,</span><br><span class="line">        justifyContent: <span class="string">'center'</span>,</span><br><span class="line">        position: <span class="string">'absolute'</span>,</span><br><span class="line">        top: <span class="number">0</span>,</span><br><span class="line">        right: <span class="number">0</span>,</span><br><span class="line">        bottom: <span class="number">0</span>,</span><br><span class="line">        left: <span class="number">0</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    viewfinder: &#123;</span><br><span class="line">        alignItems: <span class="string">'center'</span>,</span><br><span class="line">        justifyContent: <span class="string">'center'</span>,</span><br><span class="line">        backgroundColor: <span class="string">'transparent'</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    topLeftEdge: &#123;</span><br><span class="line">        position: <span class="string">'absolute'</span>,</span><br><span class="line">        top: <span class="number">0</span>,</span><br><span class="line">        left: <span class="number">0</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    topRightEdge: &#123;</span><br><span class="line">        position: <span class="string">'absolute'</span>,</span><br><span class="line">        top: <span class="number">0</span>,</span><br><span class="line">        right: <span class="number">0</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    bottomLeftEdge: &#123;</span><br><span class="line">        position: <span class="string">'absolute'</span>,</span><br><span class="line">        bottom: <span class="number">0</span>,</span><br><span class="line">        left: <span class="number">0</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">    bottomRightEdge: &#123;</span><br><span class="line">        position: <span class="string">'absolute'</span>,</span><br><span class="line">        bottom: <span class="number">0</span>,</span><br><span class="line">        right: <span class="number">0</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">&#125;);</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">Viewfinder.defaultProps = &#123;</span><br><span class="line">    backgroundColor: <span class="string">'transparent'</span>,</span><br><span class="line">    borderWidth: <span class="number">3</span>,</span><br><span class="line">    borderLength: <span class="number">20</span>,</span><br><span class="line">    color: <span class="string">'#1DBAF1'</span>,</span><br><span class="line">    height: scaleSizeH(<span class="number">300</span>),</span><br><span class="line">    isLoading: <span class="literal">false</span>,</span><br><span class="line">    width: scaleSizeH(<span class="number">300</span>),</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
<figure class="highlight js"><table><tr><td class="code"><pre><span class="line"><span class="comment">// 使用方式</span></span><br><span class="line">onScan = <span class="function"><span class="params">()</span>=&gt;</span>&#123;</span><br><span class="line">    <span class="keyword">const</span> &#123; navigate &#125; = <span class="keyword">this</span>.props.navigation;</span><br><span class="line">    <span class="comment">// 跳转到扫码页面即可打开</span></span><br><span class="line">    navigate(<span class="string">'Scan'</span>)</span><br><span class="line">&#125;</span><br><span class="line"><span class="string">`</span></span><br></pre></td></tr></table></figure>
      </div>
    
  </div>

</article>

<button class="assist-btn2 circle" id="assist_btn2" title="点亮屏幕" style="left: 27px; top: 152px;">
  <i class="iconfont" style="display:inline-block;color:red;width:20px;height:20px;">&#xe61d;</i>
</button>
<button class="assist-btn1 circle" id="assist_btn1" title="关闭屏幕亮度" style="left: 27px; top: 152px;">
  <i class="iconfont toc-title" style="display:inline-block;color:red;width:20px;height:20px;">&#xe61d;</i>
</button>


<script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>	

<script src="https://my.openwrite.cn/js/readmore.js" type="text/javascript"></script>
<script>
  const btw = new BTWPlugin();
  btw.init({
    id: "container",
    blogId: "22699-1592137983091-414",
    name: "前端进阶之旅",
    qrcode: "https://poetries1.gitee.io/img-repo/2020/06/qrcode.jpg",
    keyword: "3a3b3c",
  });
</script>

<script type="text/javascript">

// white theme
var body = {color: "#555", background: "#000"};
var a_tag = {color: "#222"};
var header = { background: "#222"};
var logo_line_i = {background: "#222"};
// var post_code = {background: "#eee", color: "#222"};

function switch_theme() {
 $("body").css(body);
 $("a:not('.links-of-author-item a, .site-state-item a, .site-state-posts a, .feed-link a, .motion-element a, .post-tags a, .show-commit-cls a, #donate_board a')").css(a_tag);
 $(".header, .footer").css(header);
 $(".logo-line-before i, .logo-line-after i").css(logo_line_i);
 //$(".post code").css(post_code);
 $("#idhyt-surprise-ball #idhyt-surprise-ball-animation .drag").css(a_tag);
 $(".post-title-link, .posts-expand .post-meta, .post-comments-count, .disqus-comment-count, .post-category a, .post-nav-next a, .post-nav-item a").css(a_tag);
 
 // $("code").css({color: '#c5c8c6', background: '#1d1f21'});
 //$("#assist_btn1").hide(1500);
}

$(function () {
$("#assist_btn2").css("display","none");
 $("#assist_btn1").click(function() {
     switch_theme();
$("div#toc.toc-article").css({
 "background":"#eaeaea",
 "opacity":1
});
$(".toc-article ol").show();
$("#toc.toc-article .toc-title").css("color","#a98602");
$("#assist_btn1").css("display","none");
$("#assist_btn2").css("display","block");
 });
$("#assist_btn2").click(function() {
$("#assist_btn2").css("display","none");
$("#assist_btn1").css("display","block");
$("body").css("background","url(http://www.miaov.com/static/ie/images/news/bg.png)")
     $(".header, .footer").css("background","url(http://www.miaov.com/static/ie/images/news/bg.png)")
$(".toc-article ol").toggle(1000);
 });
});


//背景随机

var Y, O, E, L, B, C, T, z, N, S, A, I;
!function() {
var e = function() {
for (O.clearRect(0, 0, L, B), T = [{
x: 0,
y: .7 * B + C
}, {
x: 0,
y: .7 * B - C
}]; T[1].x < L + C;) t(T[0], T[1])
}, t = function(e, t) {
O.beginPath(), O.moveTo(e.x, e.y), O.lineTo(t.x, t.y);
var n = t.x + (2 * I() - .25) * C,
 r = a(t.y);
O.lineTo(n, r), O.closePath(), N -= S / -50, O.fillStyle = "#" + (127 * A(N) + 128 << 16 | 127 * A(N + S / 3) + 128 << 8 | 127 * A(N + S / 3 * 2) + 128).toString(16), O.fill(), T[0] = T[1], T[1] = {
 x: n,
 y: r
}
}, a = function n(e) {
var t = e + (2 * I() - 1.1) * C;
return t > B || t < 0 ? n(e) : t
};
Y = document.getElementById("evanyou"), O = Y.getContext("2d"), E = window.devicePixelRatio || 1, L = window.innerWidth, B = window.innerHeight, C = 90, z = Math, N = 0, S = 2 * z.PI, A = z.cos, I = z.random, Y.width = L * E, Y.height = B * E, O.scale(E, E), O.globalAlpha = .6, document.onclick = e, document.ontouchstart = e, e()
}()

   
$("#toc-eye").click(function(){
$("#toc.toc-article").toggle(1000);
});

</script>


   
  <div class="text-center donation">
    <div class="inner-donation">
      <span class="btn-donation">支持一下</span>
      <div class="donation-body">
        <div class="tip text-center">扫一扫，支持poetries</div>
        <ul>
        
          <li class="item">
            
              <span>微信扫一扫</span>
            
            <img src="/images/weixin.jpg" alt="">
          </li>
        
          <li class="item">
            
              <span>支付宝扫一扫</span>
            
            <img src="/images/zhifubao.jpg" alt="">
          </li>
        
        </ul>
      </div>
    </div>
  </div>


   
  <div class="box-prev-next clearfix">
    <a class="show pull-left" href="/2019/10/02/rn-ble/">
        <i class="icon icon-angle-left"></i>
    </a>
    <a class="show pull-right" href="/2019/10/02/rn-adapter/">
        <i class="icon icon-angle-right"></i>
    </a>
  </div>




</div>


  <a id="backTop" class="back-top">
    <i class="icon-angle-up"></i>
  </a>




  <div class="modal" id="modal">
  <span id="cover" class="cover hide"></span>
  <div id="modal-dialog" class="modal-dialog hide-dialog">
    <div class="modal-header">
      <span id="close" class="btn-close">关闭</span>
    </div>
    <hr>
    <div class="modal-body">
      <ul class="list-toolbox">
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/archives/"
              rel="noopener noreferrer"
              target="_self"
              >
              博客
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/categories/"
              rel="noopener noreferrer"
              target="_self"
              >
              分类
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/tags/"
              rel="noopener noreferrer"
              target="_self"
              >
              标签
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/search/"
              rel="noopener noreferrer"
              target="_self"
              >
              搜索
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/link/"
              rel="noopener noreferrer"
              target="_self"
              >
              友链
            </a>
          </li>
        
          <li class="item-toolbox">
            <a
              class="CIRCLE"
              href="/about/"
              rel="noopener noreferrer"
              target="_self"
              >
              关于
            </a>
          </li>
        
      </ul>

    </div>
  </div>
</div>



  
      <div class="fexo-comments comments-post">
    

    

    
    

    

    
    

    

<!-- Gitalk评论插件通用代码 -->
<div id="gitalk-container"></div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
<script>
const gitalk = new Gitalk({
  clientID: '5567a2c4abb858009d96',
  clientSecret: 'b9039ec056cf5c2346b3cdb63308a28c163f91e5',
  repo: 'poetries.github.io',
  owner: 'poetries',
  // 在这里设置一下截取前50个字符串, 这是因为 github 对 label 的长度有了要求, 如果超过
  // 50个字符串则会报错.
  // id: location.pathname.split('/').pop().substring(0, 49),
  id: location.pathname,
  admin: ['poetries'],
  // facebook-like distraction free mode
  distractionFreeMode: false
})
gitalk.render('gitalk-container')
</script>
<!-- Gitalk代码结束 -->



  </div>

  

  <script type="text/javascript">
  function loadScript(url, callback) {
    var script = document.createElement('script')
    script.type = 'text/javascript';

    if (script.readyState) { //IE
      script.onreadystatechange = function() {
        if (script.readyState == 'loaded' ||
          script.readyState == 'complete') {
          script.onreadystatechange = null;
          callback();
        }
      };
    } else { //Others
      script.onload = function() {
        callback();
      };
    }

    script.src = url;
    document.getElementsByTagName('head')[0].appendChild(script);
  }

  window.onload = function() {
    loadScript('/js/bundle.js?235683', function() {
      // load success
    });
  }
</script>


  <!-- 页面点击小红心 -->
  <script type="text/javascript" src="/js/clicklove.js"></script>
 
  
</body>
</html>
